package com.guet.ltomanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guet.ltomanagement.entity.SysUserUnit;
import com.guet.ltomanagement.mapper.SysUserUnitMapper;
import com.guet.ltomanagement.service.SysUserUnitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sjj
 * @since 2023-03-07
 */
@Service
public class SysUserUnitServiceImpl extends ServiceImpl<SysUserUnitMapper, SysUserUnit> implements SysUserUnitService {
    @Autowired
    private SysUserUnitMapper sysUserUnitMapper;
    @Override
    public Boolean add(SysUserUnit sysUserUnit) {
        sysUserUnit.setCreated(LocalDateTime.now());
        sysUserUnit.setStatu(1);
        return sysUserUnitMapper.insert(sysUserUnit) == 1;
    }

    @Override
    public Boolean delete(Integer UserId, Integer UnitId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("user_id", UserId);
        queryWrapper.eq("unit_id", UnitId);
        return sysUserUnitMapper.delete(queryWrapper) == 1;
    }
}
